
import org.apache.hadoop.hive.ql.exec.UDF;

import java.util.regex.Pattern;

/**
 * @Author Jeremy Zheng
 * @Date 2021/3/12 9:21
 * @Version 1.0
 */
public class ContentCount extends UDF {
    public int evaluate(String content) {
        int sum=0;
        int newIndex = 0;
        while ((newIndex=content.toLowerCase().indexOf("iphone",newIndex))!=-1){
            sum++;
            newIndex+="iphone".length();
        }

        return sum;
    }
}